Skip to content

Conversation

@jwir3
Copy link

@jwir3 jwir3 commented Feb 26, 2024

This fixes #1. I'm currently using it for my personal synchronization, but I'd like to upstream the patch if possible.

This adds basic deletion of files and folders, prior to other
synchronization. This is implemented by using a queue of
delete operations that will happen prior to copying files to/from Google
drive. Once a file has been deleted, it is removed from the queue and
normal synchronization resumes.
This makes main.ts a little smaller and easier to maintain.
This adds support for renaming files, which is treated as a delete
operation of the old files followed by a creation of the new files.
"author": "Antonio Tejada",
"authorUrl": "https://github.com/antoniotejada/",
"author": "Scott Johnson and Andrewq Tejada",
"authorUrl": "https://github.com/jwir3/",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I didn't mean to make this change here. I can remove it if desired.

"author": "Antonio Tejada",
"authorUrl": "https://github.com/antoniotejada/",
"author": "Scott Johnson and Andrewq Tejada",
"authorUrl": "https://github.com/jwir3/",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"authorUrl": "https://github.com/jwir3/",
"authorUrl": "https://github.com/antoniotejada/",

@antoniotejada
Copy link
Owner

Thanks for taking the time to submit the patch, this works for simple cases but it doesn't work for the general case (and it cannot be fixed to make it work in the presence of multiple clients modifying the vault, even without conflicts), so I won't be taking it.

For example:

  • if you close obsidian before synchronizing the deletequeue is lost.
  • if there was an error when calling Google drive delete (network down, auth error, etc), the deletequeue item is lost
  • Doesn't take into account multiple clients modifying the vault (eg cell phone and desktop, which is a case I'm very interested in working):
    • The check between the file existing in google drive and deleting the file from google drive is racy (one client could have deleted the file in between).
    • Deletions on one client are not pushed to another client
    • Automatically resolve non-conflicts like a client deleting a file that was later created and modified by another client
    • Warn of conflicts that cannot be resolved like a client deleting a file that has been modified in google drive since the last sync.
  • Doesn't work for files in the vault deleted externally to obsidian (this is a very minor point).

The way to go is to have syncFolder detect deletions, see this comment https://github.com/antoniotejada/obsidian-google-drive/blob/master/main.ts#L723

I implemented that approach some time ago and I've had it working in my local copy, but want to clean it up and make it robust in the event of network disconnects and conflicts before pushing.

@jwir3
Copy link
Author

jwir3 commented Feb 26, 2024 via email

@antoniotejada
Copy link
Owner

antoniotejada commented Feb 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deletion/Renaming of Files and Folders

2 participants